
#these are the same df as generated in main_block_group_SHORT, just pre-generated 
census_blocks3<- read.csv("census_blocks3.csv")
census_blocks2<- read.csv("census_blocks2.csv")


whites<- census_blocks2 %>%
  group_by(q_white, elec_year) %>%
  summarize(Mean_q = mean(Mean, na.rm=TRUE))
whites<- whites[complete.cases(whites),]

whitegg<- ggplot(data=census_blocks2, aes(x=elec_year, y=Mean, group=bg_ct))+
  geom_line(color="grey", size=0.5)+
  geom_line(data=whites, aes(x=elec_year, y=Mean_q, group=q_white), col=c("red"))+
  ggtitle("Prop. white quartiles")+ylab("Percent donating")+ 
  scale_x_continuous(breaks= c(2005,2007,2009,2011,2013,2015))+
  theme_light()
whitegg

polparts<- census_blocks2 %>%
  group_by(sums_q, elec_year) %>%
  summarize(Mean_q = mean(Mean, na.rm=TRUE))
polpartsgg<- ggplot(data=census_blocks2, aes(x=elec_year, y=Mean, group=bg_ct))+
  geom_line(color="grey", size=0.5)+
  geom_line(data=polparts, aes(x=elec_year, y=Mean_q, group=sums_q), col=c("red"))+
  ggtitle("Voting quartiles")+
  ylab("")+ scale_x_continuous(breaks= c(2005,2007,2009,2011,2013,2015))+theme_light()
polpartsgg


incs<- census_blocks3 %>%
  group_by(inc_q, elec_year) %>%
  summarize(Mean_q = mean(Mean, na.rm=TRUE))
incs<- incs[complete.cases(incs),]

incsgg<- ggplot(data=census_blocks3, aes(x=elec_year, y=Mean, group=bg_ct19))+
  geom_line(color="grey", size=0.5)+
  geom_line(data=incs, aes(x=elec_year, y=Mean_q, group=inc_q), col=c("red"))+
  ggtitle("Income quartiles")+ylab("Percent donating")+ 
  scale_x_continuous(breaks= c(2005,2007,2009,2011,2013,2015))+
  theme_light()
incsgg
